/*主导航样式插件 main-nav.js
----------------------------
版本：		v0.1
更新时间：	2015年5月26日
作者：		三牙西瓜
参数说明：
----------------------------
*/
(function ($) {
    $.fn.extend({
        "main_nav": function (options) {
            var opts = $.extend({}, defaluts, options); 
			var spe_index = opts.spe;
			var main_nav_h = opts.height;
			var font_size = opts.ts;
			var main_nav_w = $(window).width();
			var op_size = $(this).find("li").size();
			$(this).css({
				"border-top": "1px solid #ddd",
				"background-color": "#fff",
				"height": main_nav_h + "px"
			})
			$(this).find("a").css({
				"position": "relative",
				"display": "block",
				"text-align": "center",
				"height": "100%"
			})
			$(this).find("span").css({
				"position": "absolute",
				"bottom": "2px",
				"display": "block",
				"width": "100%",
				"font-size": font_size+"px"
			});
			if(spe_index > 0 && spe_index <= op_size){
				var spe_rate = opts.rate;
				var spe_down = opts.down;
				var spe_shape = opts.shape;
				var spe_bgc = opts.bgc;
				//初始化特殊项的宽度和高度
				var spe_size = Math.ceil(main_nav_h * spe_rate);
				//初始化所有项的高、宽
				item_w = Math.floor((main_nav_w - spe_size)/(op_size-1));
				$(this).find('li').css({
					"position": "relative",
					"width": item_w,
					"height": main_nav_h,
					"float": "left"
				})
				if(spe_shape < 0 || spe_shape > 50){
					spe_shape = 50
				};
				//初始化特殊项的样式和位置
				$(this).find('li').eq(spe_index-1).css({
					"position": "absolute",
					"left": item_w*(spe_index-1)+"px",
					"bottom": spe_size*spe_down*(-1)+"px",
					"border-radius": spe_shape+"% "+spe_shape+"% "+ "0 0",
					"background-color": spe_bgc,
					"width": spe_size + "px",
					"height": spe_size + "px",
				}).addClass("spe").find("span").css({
					"bottom": Math.floor(spe_size*spe_down+3)+"px"
				});
				$(this).find('li').eq(spe_index).css({
					"margin-left": spe_size+"px"
				})
			}else{
				$(this).find('li').css({
					"width": Math.floor(main_nav_w / op_size),
					"height": main_nav_h,
					"float": "left"
				})
			};
		}
    });
	var defaluts = {
		spe: 3,			//是否需要特殊项，0为不需要，1为需要
		rate: 1.7,		//特殊项膨胀系数
		down: 0.35,		//下沉距离
		shape: 50,		//特殊项的四角的弧度，范围0-50%，0为直角，50%为圆形
		bgc: "#e73335",
		ts: 14,
		height: 56,
	}; 
})(window.jQuery);